100 '
105 ' Program to Illustrate AND and OR Functions
110 '
115 COMMON RH: IF RH=0 THEN SYSTEM
120 CLEAR: ON ERROR GOTO 580
125 KEY (17) ON: KEY 17, CHR$(0)+CHR$(1): ON KEY (17) GOSUB 570
126 KEY (18) ON: KEY 18,CHR$(32)+CHR$(1): ON KEY (18) GOSUB 570
130 SCREEN 0:KEY OFF:WIDTH 80
140 COLOR 2,0,0:DIM N(2)
150 CLS:FOR A=0 TO 6 STEP 3
160 FOR B=0 TO 42 STEP 42
170 LOCATE 10+A,15+B:PRINT CHR$(201);
180 LOCATE 11+A,15+B:PRINT CHR$(186);
190 LOCATE 12+A,15+B:PRINT CHR$(200);
200 FOR C=0 TO 14 STEP 2
210 LOCATE 10+A,16+B+C:PRINT CHR$(205);CHR$(203);
220 LOCATE 11+A,16+B+C:PRINT CHR$(32);CHR$(186);
230 LOCATE 12+A,16+B+C:PRINT CHR$(205);CHR$(202);
240 NEXT C
250 LOCATE 10+A,31+B:PRINT CHR$(187);
260 LOCATE 11+A,31+B:PRINT CHR$(186);
270 LOCATE 12+A,31+B:PRINT CHR$(188);
280 NEXT B,A
290 FOR A=1 TO 2
300 LOCATE 2+A+A,28:PRINT STRING$(10,32);STRING$(10,29);
310 PRINT STRING$(20,32);STRING$(20,29);
320 IF A=1 THEN INPUT " First Number";N(1)
330 IF A=2 THEN INPUT "Second Number";N(2)
340 IF N(A)<0 OR N(A)>255 THEN 300
350 FOR B=0 TO 42 STEP 42:LOCATE 8+A*3,9+B
360 PRINT USING "### =";N(A);:FOR C=0 TO 7
370 LOCATE 8+A*3,16+B+C*2
380 PRINT USING "#";SGN(N(A) AND 2^(7-C));
390 NEXT C,B,A:LOCATE 17,1
400 PRINT USING "### AND ### =";N(1);N(2);
410 LOCATE 17,33:PRINT "=";N(1) AND N(2);
420 A=N(1) AND N(2):FOR B=0 TO 7:LOCATE 17,16+B*2
430 PRINT USING "#";SGN(A AND 2^(7-B));
440 NEXT B:LOCATE 17,44
450 PRINT USING "### OR ### =";N(1);N(2);
460 LOCATE 17,75:PRINT "=";N(1) OR N(2);
470 A=N(1) OR N(2):FOR B=0 TO 7:LOCATE 17,58+B*2
480 PRINT USING "#";SGN(A AND 2^(7-B));
490 NEXT B:LOCATE 22,15,0
500 PRINT"Press ";:COLOR 16,2:PRINT" SPACE BAR ";
510 COLOR 2,0:PRINT" to continue or ";
520 COLOR 16,2:PRINT" ESC ";
530 COLOR 2,0:PRINT" to quit"
540 DEF SEG=0:POKE 1050,PEEK(1052)
550 A$=INKEY$:IF A$=" " THEN 150
560 IF A$ <> CHR$(27) THEN 550
570 CLS: LOCATE 12,28: PRINT "One moment please...": RUN "menu"
580 RESUME NEXT
